package A3GCPackage;

public class RankingSchemeFactory 
{
	public static RankingScheme getSystemRankingScheme()
	{
		// should try to load this in via properties file
		String value = System.getProperty("A3GCPackage.rankingscheme");
		if ( value == null )
		{
			return new BasicRankingScheme();
		}
		else
		{
			// need to try to load the class thru the ClassLoader
			try 
			{
				Class<?> loadClass = ClassLoader.getSystemClassLoader().loadClass(value);
				
				return (RankingScheme)loadClass.newInstance();
			} 
			catch (ClassNotFoundException e) 
			{
				e.printStackTrace();
				System.err.println("Could not find class <" + value + ">" );
			} 
			catch (InstantiationException e) 
			{
				e.printStackTrace();
				System.err.println("Could not instantiate class <" + value + ">" );
			}
			catch (IllegalAccessException e) 
			{
				e.printStackTrace();
				System.err.println("Access error for loading class <" + value + ">" );
			}
			catch (ClassCastException e)
			{
				e.printStackTrace();
				System.err.println("Input class cast exception on class <" + value + ">" );
			}
		}
		
		// default to the basic class if nothing available
		return new BasicRankingScheme();
	}
}
